<?php
/**
 * jishupu-cms
 * @Author:技术铺<jishupu@qq.com>
 * @Date: 2021/11/20
 */

namespace App\Http\Controllers;

use App\Services\CacheService;
use App\Services\RedisService;
use Illuminate\Support\Facades\Artisan;

/**
 * 缓存模块
 * Class CacheController
 * @package App\Http\Controllers
 */
class CacheController extends Controller
{

    /**
     * 清除所有缓存
     * @return \Illuminate\Http\JsonResponse
     */
    public function clear()
    {
        // 清除后台应用程序缓存
        CacheService::clear();
        // 更新后台接口路由缓存
        Artisan::call('route:cache');
        // 通知前台：更新应用缓存、路由
        RedisService::publishUpdateWebsiteCache();
        return $this->success(__('common.cleared'));
    }
}
